<template>
  <div class="container">
    <div>
      <el-form ref="form" :model="form">
        <el-form-item label="车辆名称：" label-width="110px">
          <el-select
            v-model="form.SIMCARD_NO"
            placeholder="请选择"
            clearable
            filterable
          >
            <el-option
              v-for="item in options"
              :key="item.CARDNO"
              :label="item.LICENSEPLATE"
              :value="item.CARDNO"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="定位间隔：" label-width="110px">
          <el-input
            v-model="form.TEXTCONTENT"
            placeholder="请输入"
            style="width: 100%"
          ></el-input>
        </el-form-item>
      </el-form>
      <el-row type="flex" justify="center">
        <el-col :span="24"
          ><div align="center">
            <el-button
              type="primary"
              @click="saveAdd"
              style="width: 100%; margin-bottom: 18px"
            >
              定 位 间 隔 设 置</el-button
            >
          </div></el-col
        >
      </el-row>
    </div>
    <el-divider>已设置车辆</el-divider>
    <el-table
      highlight-current-row
      :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      "
      border
    >
      <el-table-column
        prop="LICENSE_PLATE"
        label="车辆名称"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="CAR_TYPE"
        label="车辆类型"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="TEXTCONTENT"
        label="内容"
        align="center"
        width="400"
      ></el-table-column>
      <el-table-column
        prop="SubmitDateTime"
        label="提交时间"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="DisposeDateTime"
        label="生效时间"
        align="center"
      ></el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="tableData.length"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import '@/assets/css/common.css'

import export2Excel from '@/utils/exportExcel/index.js'
import OSS from 'ali-oss';
import { time } from 'echarts';
export default {
  data () {

    return {
      options: [],
      currentPage: 1, //初始页
      pageSize: 10,    //    每页的数据
      select: {
        CPH: ''
      },
      form: {
        SIMCARD_NO: '',
        TEXTCONTENT: '#_ZTTtsSet;其它设置;定位包回传间隔=25$',
      },
      tableData: [],
    }
  },
  mounted () {
    this.getVehicleList()
    this.getlistdata()
  },
  methods: {

    // 获得分组列表
    async getVehicleList () {
      var url = 'Vehicle/GetCarListCurrentVehicle?CLIENTNO=' + localStorage.getItem('CLIENT_NO') + '&LICENSEPLATE=&CARGROUP=&CARSTATUS=1&CARTYPE='
      let { data } = await this.$Http.get(url)
      this.options = data
    },
    // 获取车辆定位间隔信息列表
    async getlistdata () {
      var url = 'Vehicle/GetVDIssuedInsList?ClientNo=' + localStorage.getItem('CLIENT_NO')
      let { data } = await this.$Http.get(url)
      this.originalData = data
      this.screeningData()
    },
    // 保存编辑
    async saveAdd () {
      this.$axios({
        url: 'Vehicle/IssuedInsVD',
        method: 'post',
        data: {
          SIMCARD_NO: this.form.SIMCARD_NO,
          TEXTCONTENT: this.form.TEXTCONTENT,
        },

      }).then((res) => {
        console.log(this.data)
        console.log(res)
        if (res.data.IsSucess) {
          this.$message.success('设置成功');
          this.getVehicleList()
          this.getlistdata()
        } else {
          this.$message.error('设置失败');
        }
      })
    },
    // 模糊查询
    screeningData () {
      this.tableData = this.originalData
      // if (this.select.CPH) this.tableData = this.tableData.filter(item => item.CPH.includes(this.select.CPH))
    },
    // 分页导航
    handlePageChange (currentPage) {
      this.currentPage = currentPage;
      // console.log(this.currentPage)
      // this.$set(this.query, 'pageIndex', val);
      this.getlistdata();
    },
    handleSizeChange (size) {
      this.pageSize = size;
      console.log(this.pageSize)
    }
  }
}
</script>
<style>
.el-form-item__label {
  text-align: left;
}
/* .el-checkbox {
  color: #fff;
}
.el-checkbox__label {
  color: #fff !important;
} */
.content {
  overflow-y: scroll;
}
.el-col-6 {
  width: 350px;
  min-height: 50px;
}
.el-table th {
  height: 40px;
}
.el-form-item label {
  width: 80px;
}
.el-tag + .el-tag {
  margin-left: 10px;
}
.button-new-tag {
  margin-left: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}
.input-new-tag {
  height: 32px;
  line-height: 30px;
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}
.aroundtop {
  padding: 10px;
  background-color: #007acc;
  height: 100%;
  border-radius: 5px;
}
.el-icon-speed {
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  height: 30px;
  line-height: 28px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  margin: 10px 20px 10px 20px;
}
</style>
